/**============ 正则表达式开始 ============**/
var ZZ_USER_NAME = /^[a-zA-Z]{1}[a-zA-Z0-9_]{5,19}$/;
var ZZ_PASSWORD = /^[a-zA-Z0-9._]{6,20}$/;
var ZZ_MOBILE = /^1[3,4,5,7,8]{1}[0-9]{9}$/;
var ZZ_EMAIL = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
var ZZ_ACTUAL_NAME = /^[\u4E00-\u9FA5\uF900-\uFA2D]{2,10}/;
var ZZ_ID_CARDID = /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X|x)$/;
var ZZ_REGISTER_SOURCE = /^[a-zA-Z0-9]{3,10}$/;
var ZZ_CAPTCHA = /^[a-zA-Z0-9]{4}$/;
var ZZ_CHECK_CAPTCHA = /^[0-9]{5}$/;
var ZZ_CARD_NUMBER = /^\d{10,20}$/;
/**============ 正则表达式结束 ============**/

$(function(){
	
	$('.promptToast .close').click(function(){
		$('.promptToast, .translucent').hide();
		return false;
	});
	
});

/*打开自定义弹出层*/
$.fn.showToast = function(){
	$('.translucent').show();
	$(this).show();
}
/*关闭自定义弹出层*/
$.fn.closeToast = function(){
	$('.translucent').hide();
	$(this).hide();
}

/**
 * 数字格式化
 * param
 *		.text	需要格式化的数据
 *		.format	格式化类型
 *				('cardNumber':卡号，四位添加一个空格分离)
 *
 */
function digitalFormat(param){
	if(param.format=='cardNumber'){
		var textArr = param.text.split(''), text = '';
		for(var i=0,len=textArr.length; i<len; i++){
			if(textArr[i]>='0' && textArr[i]<='9'){
				text += textArr[i];
				if(text.length%5==4 && i!=len-1){
					text += ' ';
				}
			}
		}
		return text;
	}
}
/**
 * 添加Cookie
 */
function setCookie(name, value){
	var Days=30;
    var exp=new Date();
    exp.setTime(exp.getTime()+Days*24*60*60*1000);//30天过期
    document.cookie= name+"="+escape(value)+";expires="+exp.toGMTString()+";path=/";
}   
/**
 * 获取Cookie
 * @param name		key
 * @param coding	是否需要转编码，如果值为N，那么直接返回结果
 */
function getCookie(name, coding){
	var arr=document.cookie.match(new RegExp("(^|)"+name+"=([^;]*)(;|$)"));   
	if(arr!=null){
		if(coding=='N' || coding=='n'){
			return arr[2];
		}else{
			return unescape(arr[2]);
		}
	}
	return null;   
}
/**
 * 删除Cookie
 */
function delCookie(name){   
	var exp=new Date();   
	exp.setTime(exp.getTime()-1);   
	var cval = getCookie(name);   
	if(cval!=null){
		document.cookie=name +"="+cval+";expires="+exp.toGMTString()+";path=/";
	}
}

var MD0_CONNECTION_CHAR = '-';
var MD0_ENCRYPTION_NUM = 1;
function decryptionMD0ofStr(str){
	if(str!=null && str.length>0){
		var strs = str.split(MD0_CONNECTION_CHAR);
		if(strs.length > 0){
			var random = parseInt(strs[0]);
			var sb = '';
			var str_test = 0;
			for(var i=1,len=strs.length; i<len; i++){
				str_test = parseInt(strs[i]) - random;
				sb += String.fromCharCode(str_test);
			}
			var MD0_RESULT_STR = sb;
			MD0_ENCRYPTION_NUM --;
			if(MD0_ENCRYPTION_NUM > 0){
				decryptionMD0ofStr(MD0_RESULT_STR);
			}
		}
	}
	return MD0_RESULT_STR;
}